package service

import (
	"context"
	"day11/video-mngr/video-server/basic/handler/model"
	"day11/video-mngr/video-server/basic/proto"
)

type Server struct {
	proto.UnimplementedVideoServer
}

func (s Server) CreateVideo(_ context.Context, in *proto.CreateVideoReq) (*proto.CreateVideResp, error) {
	//TODO implement me

	var video model.Video
	video = model.Video{
		Title:    in.Title,
		Status:   in.Status,
		VideoUrl: in.VideoUrl,
	}
	err := model.CreateVideo(&video)
	if err != nil {
		return &proto.CreateVideResp{
			Code: 0,
			Msg:  "添加失败",
		}, nil
	}
	return &proto.CreateVideResp{
		Code: 200,
		Msg:  "添加成功",
	}, nil
}
func (s Server) CreateDrama(_ context.Context, in *proto.CreateDramaReq) (*proto.CreateDramaResp, error) {

	var drama model.Drama
	drama = model.Drama{
		VideoId: int(in.VideoId),
		Title:   in.Title,
		Address: in.Address,
		Count:   int(in.Count),
		Vip:     in.Vip,
	}
	err := model.CreateDrama(&drama)
	if err != nil {
		return &proto.CreateDramaResp{
			Code: 0,
			Msg:  "添加失败",
		}, nil
	}
	return &proto.CreateDramaResp{
		Code: 200,
		Msg:  "添加成功",
	}, nil
}
